/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.cx1.service.impl.deprecated;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import org.apache.commons.lang.StringUtils;
import org.cx1.model.ds.MockDS;
import org.cx1.model.deprecated.REDealType;
import org.cx1.model.deprecated.RETypeL1;
import org.cx1.model.deprecated.RETypeL2;
import org.cx1.model.utils.ServiceResponse;
import org.cx1.service.api.deprecated.IRETypeService;

/**
 *
 * @author ECH
 */
public class RETypeService implements IRETypeService {

    /*
    @Override
    public ServiceResponse<List<RETypeL1>> getRETypeL1All() {
        ServiceResponse<List<RETypeL1>> response = new ServiceResponse<List<RETypeL1>>();
        List<RETypeL1> RETypeL1s = new ArrayList<RETypeL1>();
        try {
            List<RETypeL1> records = MockDS.getReTypesL1();
            if (records != null && records.size() > 0) {
                for (RETypeL1 record : records) {
                    if (record.isActive()) {
                        RETypeL1s.add(record);
                    }
                }
            }
            response.setResponse(RETypeL1s);
            response.setSuccessful(true);            
        } catch (Exception ex) {
            response.setResponse(null);
            response.setSuccessful(false);
            response.setMessage(ex.getMessage());
            response.setException(ex);
            ex.printStackTrace();            
        }
        return response; 
    }

    @Override
    public ServiceResponse<RETypeL1> getRETypeL1(String id) {
        ServiceResponse<RETypeL1> response = new ServiceResponse<RETypeL1>();
        RETypeL1 re = null;
        try {
            List<RETypeL1> RETypeL1s = MockDS.getReTypesL1();
            if (RETypeL1s != null && RETypeL1s.size() > 0) {
                for (RETypeL1 record : RETypeL1s) {
                    if (StringUtils.equalsIgnoreCase(record.getId(), id)) {
                        re = record;
                        break;
                    }
                }
            }
            response.setResponse(re);
            response.setSuccessful(true);            
        } catch (Exception ex) {
            response.setResponse(null);
            response.setSuccessful(false);
            response.setMessage(ex.getMessage());
            response.setException(ex);
            ex.printStackTrace();            
        }
        return response; 
    }

    @Override
    public ServiceResponse<String> addRETypeL1(String title, String desc) {
        ServiceResponse<String> response = new ServiceResponse<String>();
        String id = null;
        
        try {            
            RETypeL1 re = new RETypeL1();
            id = UUID.randomUUID().toString();
            
            re.setId(id);
            re.setTitle(title);
            re.setDescription(desc);
            
            re.setActive(true);
            re.setDateCreated(new Date());
            
            MockDS.getReTypesL1().add(re);
            
            response.setResponse(id);
            response.setSuccessful(true);
            
        } catch (Exception ex) {
            response.setResponse(null);
            response.setSuccessful(false);
            response.setMessage(ex.getMessage());
            response.setException(ex);
            ex.printStackTrace();            
        }
        return response;    
    }

    @Override
    public ServiceResponse<Boolean> deactivateRETypeL1(String id) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public ServiceResponse<List<RETypeL2>> getRETypeL2All() {
        ServiceResponse<List<RETypeL2>> response = new ServiceResponse<List<RETypeL2>>();
        List<RETypeL2> reTypeL2List = new ArrayList<RETypeL2>();
        try {
            List<RETypeL2> records = MockDS.getReTypesL2();
            if (records != null && records.size() > 0) {
                for (RETypeL2 record : records) {
                    if (record.isActive()) {
                        reTypeL2List.add(record);
                    }
                }
            }
            response.setResponse(reTypeL2List);
            response.setSuccessful(true);            
        } catch (Exception ex) {
            response.setResponse(null);
            response.setSuccessful(false);
            response.setMessage(ex.getMessage());
            response.setException(ex);
            ex.printStackTrace();            
        }
        return response; 
    }

    @Override
    public ServiceResponse<RETypeL2> getRETypeL2(String id) {
        ServiceResponse<RETypeL2> response = new ServiceResponse<RETypeL2>();
        RETypeL2 re = null;
        try {
            List<RETypeL2> reTypeL2List = MockDS.getReTypesL2();
            if (reTypeL2List != null && reTypeL2List.size() > 0) {
                for (RETypeL2 record : reTypeL2List) {
                    if (StringUtils.equalsIgnoreCase(record.getId(), id)) {
                        re = record;
                        break;
                    }
                }
            }
            response.setResponse(re);
            response.setSuccessful(true);            
        } catch (Exception ex) {
            response.setResponse(null);
            response.setSuccessful(false);
            response.setMessage(ex.getMessage());
            response.setException(ex);
            ex.printStackTrace();            
        }
        return response; 
    }

    @Override
    public ServiceResponse<String> addRETypeL2(String title, String desc) {
        ServiceResponse<String> response = new ServiceResponse<String>();
        String id = null;
        
        try {            
            RETypeL2 re = new RETypeL2();
            id = UUID.randomUUID().toString();
            
            re.setId(id);
            re.setTitle(title);
            re.setDescription(desc);
            
            re.setActive(true);
            re.setDateCreated(new Date());
            
            MockDS.getReTypesL2().add(re);
            
            response.setResponse(id);
            response.setSuccessful(true);
            
        } catch (Exception ex) {
            response.setResponse(null);
            response.setSuccessful(false);
            response.setMessage(ex.getMessage());
            response.setException(ex);
            ex.printStackTrace();            
        }
        return response;    
    }

    @Override
    public ServiceResponse<Boolean> deactivateRETypeL2(String id) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public ServiceResponse<List<REDealType>> getREDealTypeAll() {
        ServiceResponse<List<REDealType>> response = new ServiceResponse<List<REDealType>>();
        List<REDealType> reDealTypeList = new ArrayList<REDealType>();
        try {
            List<REDealType> records = MockDS.getReDealTypes();
            if (records != null && records.size() > 0) {
                for (REDealType record : records) {
                    if (record.isActive()) {
                        reDealTypeList.add(record);
                    }
                }
            }
            response.setResponse(reDealTypeList);
            response.setSuccessful(true);            
        } catch (Exception ex) {
            response.setResponse(null);
            response.setSuccessful(false);
            response.setMessage(ex.getMessage());
            response.setException(ex);
            ex.printStackTrace();            
        }
        return response; 
    }

    @Override
    public ServiceResponse<REDealType> getREDealType(String id) {
        ServiceResponse<REDealType> response = new ServiceResponse<REDealType>();
        REDealType re = null;
        try {
            List<REDealType> reDealTypeList = MockDS.getReDealTypes();
            if (reDealTypeList != null && reDealTypeList.size() > 0) {
                for (REDealType record : reDealTypeList) {
                    if (StringUtils.equalsIgnoreCase(record.getId(), id)) {
                        re = record;
                        break;
                    }
                }
            }
            response.setResponse(re);
            response.setSuccessful(true);            
        } catch (Exception ex) {
            response.setResponse(null);
            response.setSuccessful(false);
            response.setMessage(ex.getMessage());
            response.setException(ex);
            ex.printStackTrace();            
        }
        return response; 
    }

    @Override
    public ServiceResponse<String> addREDealType(String title, String desc) {
        ServiceResponse<String> response = new ServiceResponse<String>();
        String id = null;
        
        try {            
            REDealType re = new REDealType();
            id = UUID.randomUUID().toString();
            
            re.setId(id);
            re.setTitle(title);
            re.setDescription(desc);
            
            re.setActive(true);
            re.setDateCreated(new Date());
            
            MockDS.getReDealTypes().add(re);
            
            response.setResponse(id);
            response.setSuccessful(true);
            
        } catch (Exception ex) {
            response.setResponse(null);
            response.setSuccessful(false);
            response.setMessage(ex.getMessage());
            response.setException(ex);
            ex.printStackTrace();            
        }
        return response;    
    }

    @Override
    public ServiceResponse<Boolean> deactivateREDealType(String id) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    */
    
}
